package com.hopetech.activemqdemo.publish_subscribe;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jms.Destination;

@Service
public class Publisher {
    @Resource
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void publish(String dest, String msg){
        Destination destination = new ActiveMQQueue(dest);
        System.out.println("--->>>发布topic消息 " + msg);
        jmsMessagingTemplate.convertAndSend(destination, msg);
    }
}
